<template>
  <div>
    <template v-for="navMenu in navMenus">
      <el-submenu v-if="navMenu.children.length > 0" :index="navMenu.id" :key="navMenu.id">
        <template slot="title">
          <i :class="navMenu.icon"></i>
          <span slot="title">{{navMenu.name}}</span>
        </template>
        <NavMenu :navMenus ="navMenu.children"></NavMenu>
      </el-submenu>
      <el-menu-item v-else :index="navMenu.routerUrl" :key="navMenu.id">
        <i :class="navMenu.icon"></i>
        <span slot="title">{{navMenu.name}}</span>
      </el-menu-item>
    </template>
  </div>
</template>

<script>
export default {
  name: 'NavMenu',
  props: ['navMenus'],
  data () {
    return {}
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.el-menu--collapse>div>.el-submenu>.el-submenu__title span {
  height: 0;
  width: 0;
  overflow: hidden;
  visibility: hidden;
  display: inline-block;
}
</style>
